package grex.Nodes;

public class KnnNeighbour implements Comparable{

       private double distance,attrDistance=-1;
       private double[] instance;
       private String fold;
       public KnnNeighbour(double[] instance, double distance, String fold) {
           this.instance = instance;
           this.distance = distance;
           this.fold=fold;
       }
      public KnnNeighbour(double[] instance, double distance) {
           this.instance = instance;
           this.distance = distance;
       }
       public String getFold(){
           return fold;
       }

       public double[] getInstance() {
           return instance;
       }

       public double getDistance() {
           return distance;
       }

       public void setDistance(double distance) {
           this.distance = distance;
       }

       public void setInstance(double[] instance) {
           this.instance = instance;
       }
       public KnnNeighbour clone(){
           return new KnnNeighbour(instance, distance,fold);
           
       }

        public int compareTo(Object o) {
            if(o instanceof KnnNeighbour){
                KnnNeighbour n =  (KnnNeighbour) o;
                if(n.distance < this.distance)
                    return 1;
                if(n.distance > this.distance)
                    return -1;
                if(n.instance==instance)
                    return 0;
                
            }
            return 1;
        }
    @Override
        public boolean equals(Object o){
            if(o instanceof KnnNeighbour){
                KnnNeighbour n = (KnnNeighbour)o;
                if(n.instance==instance)
                    return true;
            }
            return false;
        }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 13 * hash + (this.instance != null ? this.instance.hashCode() : 0);
        return hash;
    }

    public double getAttrDistance() {
        return attrDistance;
    }

    public void setAttrDistance(double attrDistance) {
        this.attrDistance = attrDistance;
    }
      }